import React from 'react';
import * as asyncLoad from '../util/asyncLoad';
import { portalFiles } from '../constants/fileConfig';
import Loading from './Loading';

class Synergy extends React.Component{
    constructor(){
        super();
        this.state = {hasLoad: false};
    }
    componentDidMount(){
        const init = () =>{
            this.setState({hasLoad: true});
        }
        asyncLoad.asyncLoadModule('portal', portalFiles, init, false);
    }
    render(){
        const { hasLoad } = this.state;
        if(hasLoad){
            const { Synergy } = window.weaPortal;
            return (<Synergy ecId={`${this && this.props && this.props.ecId || ''}_Synergy@q03t9g`} {...this.props} />);
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@hxddjz`} />);
        }
    }
}

class Homepage extends React.Component{
    constructor(){
        super();
        this.state = {hasLoad: false};
    }
    componentDidMount(){
        const init = () =>{
            this.setState({hasLoad: true});
        }
        asyncLoad.asyncLoadModule('portal', portalFiles, init, false);
    }
    render(){
        const { hasLoad } = this.state;
        if(hasLoad){
            const { Homepage } = window.weaPortal;
            return (<Homepage ecId={`${this && this.props && this.props.ecId || ''}_Homepage@6uptr1`} {...this.props} />);
        }else{
            return (<Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@cmj7an`} />);
        }
    }
}

export { Synergy,Homepage };